package com.topcoder.srm511;

public class FiveHundredEleven {
	private int 	N;
	private int[][] dp;
	private int[] 	cards;
	
	public String theWinner(int[] cards) {
		this.cards = cards;
		N = cards.length;
		dp = new int[512][N+1];
		int winner = solve(0, 0);
		return winner==1? "Fox Ciel" : "Toastman";
	}
	
	private int solve(int or, int remainder) {
		if (dp[or][remainder] > 0) return dp[or][remainder];
		int n = N - remainder;
		for (int i : cards) {
			int nextOr = i | or;
			if (nextOr > or) {
				if (nextOr != 511 && solve(nextOr, remainder + 1) == 2) {
					dp[or][remainder] = 1;
					return 1;
				}
				n--;
			}
		}
		
		if (n > 0) {
			if (solve(or, remainder + 1) == 2) {
				dp[or][remainder] = 1;
				return 1;
			}
		}
		
		dp[or][remainder] = 2;
		return 2;
	}
}
